import {ref} from 'vue'
import {defineStore} from 'pinia'
import {isObject} from '@/utils/type'
import {USER_UPDATE_MODAL} from '@/utils/constant'

const userUpdateModal = defineStore(USER_UPDATE_MODAL, () => {
  const userData = ref({})

  function updateUserData(data) {
    if (!Object.keys(data).length) return
    if (!isObject(data)) {
      throw new Error(`data must be object, got ${typeof data}`)
    }

    userData.value = data
  }

  return {
    userData, updateUserData
  }
})

export default userUpdateModal